﻿//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Mapping Application Block
//===============================================================================

using System;
using System.ComponentModel;
using System.Drawing.Design;
using Microsoft.Practices.EnterpriseLibrary.Configuration.Design;
using Microsoft.Practices.EnterpriseLibrary.Configuration.Design.Validation;

namespace EntLibContrib.Mapping.Configuration.Design
{
	/// <summary>
	/// This class represents a link between a data value in a table and a super type
	/// </summary>
	public class SuperType
	{
		#region Fields
		private string dataValue;
		private string superTypeName;
		#endregion

		#region Properties
		/// <summary>
		/// Gets or sets the data value that represents the super type.
		/// </summary>
		[Required]
		public string DataValue
		{
			get { return dataValue; }
			set { this.dataValue = value; }
		}

		/// <summary>
		/// Gets or sets the domain object super type name.
		/// </summary>
		[Required]
		[Editor(typeof(TypeSelectorEditor), typeof(UITypeEditor))]
		[BaseType(typeof(Object))]
		public string SuperTypeName
		{
			get { return superTypeName; }
			set { this.superTypeName = value; }
		}
		#endregion

		#region Construction
		/// <summary>
		/// Initialize a new instance of the <see cref="SuperType"/> class.
		/// </summary>
		public SuperType()
		{ }

		/// <summary>
		/// Initialize a new instance of the <see cref="SuperType"/> class.
		/// </summary>
		/// <param name="dataValue">The data value.</param>
		/// <param name="superTypeName">Name of the super type.</param>
		public SuperType(string dataValue, string superTypeName)
		{
			this.dataValue = dataValue;
			this.superTypeName = superTypeName;
		}
		#endregion

		#region Public Methods
		/// <summary>
		/// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
		/// </summary>
		/// <returns>
		/// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
		/// </returns>
		public override string ToString()
		{
			return this.dataValue;
		}
		#endregion
	}
}
